package com.bc.commoncore.util;


import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * Created by Alex on 2016/5/25.
 */
public class SnUtils {
    private static final String FORMAT = "yyMMddHHmmss";
    private static final Format DF = new SimpleDateFormat(FORMAT);


    /*
    * 生成23位流水号
    * auth:xiaoy
    * time:2016/5/25 17:41
    * */
    public static String getCode() {
        boolean lt = false;
        int a = UUID.randomUUID().hashCode();
        String len;
        if (a > 0) {
            lt = true;
        } else {
            a = Math.abs(a);
        }

        String dd = "" + a;
        if (dd.length() < 10) {
            int dif = 10 - dd.length();
            for (int i = 0; i < dif; i++) {
                dd = "0" + dd;
            }
        }
        if (lt) {

            len = DF.format(new Date()) + 1;
        } else {
            len = DF.format(new Date()) + 0;
        }
        len = len + dd;
        return len;
    }
}
